package binarytree

func buildTree106(inorder []int, postorder []int) *TreeNode {

	if len(inorder) == 0 {
		return nil
	}

	father := &TreeNode{
		Val: postorder[len(postorder)-1],
	}

	index := 0
	for inorder[index] != father.Val {
		index++
	}

	father.Left = buildTree106(inorder[:index], postorder[:index])
	father.Right = buildTree106(inorder[index+1:], postorder[index:len(postorder)-1])
	return father
}
